package com.example.filetest;

import java.io.File;

/*
 * 删除文件夹
 * */
public class Test12 {
    public static void main(String[] args) {

        File file = new File("D:\\27162\\Desktop\\new");
        delete(file);


    }

    static void delete(File file) {
        //删除文件夹里边内容
        File[] files = file.listFiles();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isFile()) files[i].delete();
            else {
                delete(files[i]);
            }
        }
        //删除自身
        file.delete();
    }

}
